package com.xx.util;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * MBG github:
 * https://github.com/mybatis/generator
 * <p>
 * MBG:
 * http://mybatis.org/generator/configreference/xmlconfig.html
 */
public class MyBatisGeneratorHelper {

    /**
     * @throws InvalidConfigurationException
     * @throws SQLException
     * @throws IOException
     * @throws InterruptedException
     */
    public static void db2Pojo() throws InvalidConfigurationException, SQLException, IOException, InterruptedException {
        List<String> warnings = new ArrayList<String>();
        Configuration config = new Configuration();


        // todo  ... fill out the config object as appropriate...

        DefaultShellCallback callback = new DefaultShellCallback(true);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
        myBatisGenerator.generate(null);
    }
}
